<!DOCTYPE HTML>
<html lang="zh-tw" >
    <!-- Start book python基础语言 -->
    <head>
        <!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>模块介绍 | python基础语言</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-splitter/splitter.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-emphasize/plugin.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../08day/section.8.html" />
    
    
    <link rel="prev" href="../10day/section.3.2.html" />
    

        <!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
        
    <div class="book"
        data-level="8.8"
        data-chapter-title="模块介绍"
        data-filepath="08day/section.7.md"
        data-basepath=".."
        data-revision="Sat Aug 12 2017 10:09:16 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Python基础
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="03day/index.html">
            
                
                    <a href="../03day/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        认识python和基础知识
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="linux/操作系统（科普章节）.html">
            
                
                    <a href="../linux/操作系统（科普章节）.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        操作系统（科普章节）
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="03day/section.1.html">
            
                
                    <a href="../03day/section.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        认识python(了解)
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="03day/section.2.html">
            
                
                    <a href="../03day/section.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        第一个python程序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="03day/section.3.html">
            
                
                    <a href="../03day/section.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        注释
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="03day/section.4.html">
            
                
                    <a href="../03day/section.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        变量以及类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="03day/section.5.html">
            
                
                    <a href="../03day/section.5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        标示符和关键字
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="03day/section.6.html">
            
                
                    <a href="../03day/section.6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.</b>
                        
                        输出
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="03day/section.4.1.html">
            
                
                    <a href="../03day/section.4.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.8.</b>
                        
                        输入
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="03day/section.7.html">
            
                
                    <a href="../03day/section.7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.9.</b>
                        
                        运算符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="03day/section.10.html">
            
                
                    <a href="../03day/section.10.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.10.</b>
                        
                        数据类型转换
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="04day/section.1.html">
            
                
                    <a href="../04day/section.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.11.</b>
                        
                        判断语句介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="04day/section.2.html">
            
                
                    <a href="../04day/section.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.12.</b>
                        
                        if语句
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="04day/section.3.html">
            
                
                    <a href="../04day/section.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.13.</b>
                        
                        比较、关系运算符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="03day/section.99.html">
            
                
                    <a href="../03day/section.99.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.14.</b>
                        
                        作业
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="03day/section.8.html">
            
                
                    <a href="../03day/section.8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.15.</b>
                        
                        附录-推荐的python电子书
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="04day/index.html">
            
                
                    <a href="../04day/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        判断语句和循环语句
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="04day/section.4.html">
            
                
                    <a href="../04day/section.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        if-else
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="04day/section.4.1.html">
            
                
                    <a href="../04day/section.4.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        elif
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="04day/section.5.html">
            
                
                    <a href="../04day/section.5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        if嵌套
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="04day/section.6.html">
            
                
                    <a href="../04day/section.6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        if应用:猜拳游戏
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="04day/section.7.html">
            
                
                    <a href="../04day/section.7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        循环语句介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="04day/section.8.html">
            
                
                    <a href="../04day/section.8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        while循环
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="04day/section.8.1.html">
            
                
                    <a href="../04day/section.8.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        while循环应用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="04day/section.10.html">
            
                
                    <a href="../04day/section.10.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                        break和continue
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="04day/section.9.html">
            
                
                    <a href="../04day/section.9.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.</b>
                        
                        while循环的嵌套以及应用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="04day/section.11.html">
            
                
                    <a href="../04day/section.11.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.10.</b>
                        
                        for循环
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.11" data-path="04day/section.12.html">
            
                
                    <a href="../04day/section.12.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.11.</b>
                        
                        总结
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.12" data-path="04day/section.99.html">
            
                
                    <a href="../04day/section.99.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.12.</b>
                        
                        作业
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="05day/index.html">
            
                
                    <a href="../05day/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        字符串、列表、元组、字典
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="05day/section.1.html">
            
                
                    <a href="../05day/section.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        字符串介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="05day/section.2.html">
            
                
                    <a href="../05day/section.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        字符串输出
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="05day/section.3.html">
            
                
                    <a href="../05day/section.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        字符串输入
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="05day/section.4.html">
            
                
                    <a href="../05day/section.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        下标和切片
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="05day/section.4.2.html">
            
                
                    <a href="../05day/section.4.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        字符串常见操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="05day/section.5.html">
            
                
                    <a href="../05day/section.5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        列表介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="05day/section.6.html">
            
                
                    <a href="../05day/section.6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                        列表的循环遍历
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="05day/section.7.html">
            
                
                    <a href="../05day/section.7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.8.</b>
                        
                        列表的常见操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="05day/section.8.html">
            
                
                    <a href="../05day/section.8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.9.</b>
                        
                        列表的嵌套
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.10" data-path="06day/section.3.html">
            
                
                    <a href="../06day/section.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.10.</b>
                        
                        元组
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.11" data-path="06day/section.1.html">
            
                
                    <a href="../06day/section.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.11.</b>
                        
                        字典介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.12" data-path="06day/section.2.html">
            
                
                    <a href="../06day/section.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.12.</b>
                        
                        字典的常见操作1
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.13" data-path="06day/section.2.1.html">
            
                
                    <a href="../06day/section.2.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.13.</b>
                        
                        字典的常见操作2
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.14" data-path="06day/section.2.2.html">
            
                
                    <a href="../06day/section.2.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.14.</b>
                        
                        字典的遍历
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.15" data-path="06day/section.2.3.html">
            
                
                    <a href="../06day/section.2.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.15.</b>
                        
                        公共方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.16" data-path="05day/section.99.html">
            
                
                    <a href="../05day/section.99.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.16.</b>
                        
                        作业
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="06day/index.html">
            
                
                    <a href="../06day/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        函数
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="07day/section.1.html">
            
                
                    <a href="../07day/section.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        函数介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="07day/section.2.html">
            
                
                    <a href="../07day/section.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        函数定义、调用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="07day/section.2.1.html">
            
                
                    <a href="../07day/section.2.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        函数的文档说明
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="07day/section.3.html">
            
                
                    <a href="../07day/section.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        函数参数(一)
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="07day/section.4.html">
            
                
                    <a href="../07day/section.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        函数返回值(一)
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="07day/section.5.html">
            
                
                    <a href="../07day/section.5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.6.</b>
                        
                        4种函数的类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="07day/section.6.html">
            
                
                    <a href="../07day/section.6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.7.</b>
                        
                        函数的嵌套调用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="07day/section.6.1.html">
            
                
                    <a href="../07day/section.6.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.8.</b>
                        
                        函数应用：打印图形和数学计算
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="07day/section.7.0.html">
            
                
                    <a href="../07day/section.7.0.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.</b>
                        
                        局部变量
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="07day/section.8.html">
            
                
                    <a href="../07day/section.8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.10.</b>
                        
                        全局变量
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="07day/section.8.1.html">
            
                
                    <a href="../07day/section.8.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.11.</b>
                        
                        函数应用：学生管理系统
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="06day/section.4.1.html">
            
                
                    <a href="../06day/section.4.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.12.</b>
                        
                        函数返回值(二)
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.13" data-path="06day/section.3.1.html">
            
                
                    <a href="../06day/section.3.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.13.</b>
                        
                        函数参数(二)
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.14" data-path="06day/section.2.4.html">
            
                
                    <a href="../06day/section.2.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.14.</b>
                        
                        引用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.15" data-path="07day/section.9.html">
            
                
                    <a href="../07day/section.9.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.15.</b>
                        
                        递归函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.16" data-path="07day/section.9.1.html">
            
                
                    <a href="../07day/section.9.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.16.</b>
                        
                        匿名函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.17" data-path="07day/section.7.html">
            
                
                    <a href="../07day/section.7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.17.</b>
                        
                        函数使用注意事项
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.18" data-path="07day/section.99.html">
            
                
                    <a href="../07day/section.99.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.18.</b>
                        
                        作业
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="08day/index.html">
            
                
                    <a href="../08day/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        文件操作、综合应用
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="08day/section.1.html">
            
                
                    <a href="../08day/section.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        文件操作介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="08day/section.2.html">
            
                
                    <a href="../08day/section.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        文件的打开与关闭
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="08day/section.3.html">
            
                
                    <a href="../08day/section.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        文件的读写
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="08day/section.3.1.html">
            
                
                    <a href="../08day/section.3.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        应用1:制作文件的备份
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="08day/section.4.html">
            
                
                    <a href="../08day/section.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        文件的定位读写
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="08day/section.5.html">
            
                
                    <a href="../08day/section.5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        文件、文件夹的相关操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="08day/section.9.html">
            
                
                    <a href="../08day/section.9.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        应用2:批量修改文件名
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="08day/section.99.html">
            
                
                    <a href="../08day/section.99.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.</b>
                        
                        作业
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="09day/index.html">
            
                
                    <a href="../09day/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        面向对象1
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="09day/section.1.html">
            
                
                    <a href="../09day/section.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        面向对象编程介绍(1)
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="09day/section.16.html">
            
                
                    <a href="../09day/section.16.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        面向对象编程介绍(2)
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="09day/section.2.html">
            
                
                    <a href="../09day/section.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        类和对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="09day/section.3.html">
            
                
                    <a href="../09day/section.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        定义类
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="09day/section.4.html">
            
                
                    <a href="../09day/section.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        创建对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="09day/section.5.1.html">
            
                
                    <a href="../09day/section.5.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                        应用:创建多个对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="09day/section.4.1.html">
            
                
                    <a href="../09day/section.4.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                        self
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="09day/section.5.html">
            
                
                    <a href="../09day/section.5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.8.</b>
                        
                        __init__方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.9" data-path="09day/section.4.4.html">
            
                
                    <a href="../09day/section.4.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.9.</b>
                        
                        &quot;魔法&quot;方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.10" data-path="09day/section.5.2.html">
            
                
                    <a href="../09day/section.5.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.10.</b>
                        
                        应用:烤地瓜
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.11" data-path="09day/section.5.4.html">
            
                
                    <a href="../09day/section.5.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.11.</b>
                        
                        隐藏数据
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.12" data-path="09day/section.5.3.html">
            
                
                    <a href="../09day/section.5.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.12.</b>
                        
                        应用:存放家具
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="10day/index.html">
            
                
                    <a href="../10day/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        面向对象2
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="09day/section.4.3.html">
            
                
                    <a href="../09day/section.4.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        保护对象的属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="09day/section.6.html">
            
                
                    <a href="../09day/section.6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        __del__方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="09day/section.7.html">
            
                
                    <a href="../09day/section.7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.3.</b>
                        
                        单继承
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4" data-path="09day/section.8.html">
            
                
                    <a href="../09day/section.8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.</b>
                        
                        多继承
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5" data-path="09day/section.8.1.html">
            
                
                    <a href="../09day/section.8.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.</b>
                        
                        重写父类方法与调用父类方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.6" data-path="09day/section.9.html">
            
                
                    <a href="../09day/section.9.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.</b>
                        
                        多态
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7" data-path="09day/section.9.1.html">
            
                
                    <a href="../09day/section.9.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.</b>
                        
                        类属性、实例属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.8" data-path="09day/section.10.html">
            
                
                    <a href="../09day/section.10.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.8.</b>
                        
                        静态方法和类方法
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="8" data-path="11day/index.html">
            
                
                    <a href="../11day/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        面向对象3、异常、模块
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="11day/section.4.html">
            
                
                    <a href="../11day/section.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        __new__方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="09day/section.13.html">
            
                
                    <a href="../09day/section.13.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        单例模式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="10day/section.1.html">
            
                
                    <a href="../10day/section.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        异常介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="10day/section.2.html">
            
                
                    <a href="../10day/section.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.4.</b>
                        
                        捕获异常
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.5" data-path="10day/section.2.2.html">
            
                
                    <a href="../10day/section.2.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.5.</b>
                        
                        异常的传递
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.6" data-path="10day/section.3.html">
            
                
                    <a href="../10day/section.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.6.</b>
                        
                        抛出自定义的异常
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.7" data-path="10day/section.3.2.html">
            
                
                    <a href="../10day/section.3.2.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.7.</b>
                        
                        异常处理中抛出异常
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="8.8" data-path="08day/section.7.html">
            
                
                    <a href="../08day/section.7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.8.</b>
                        
                        模块介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.9" data-path="08day/section.8.html">
            
                
                    <a href="../08day/section.8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.9.</b>
                        
                        模块制作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.10" data-path="08day/section.8.3.html">
            
                
                    <a href="../08day/section.8.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.10.</b>
                        
                        模块中的__all__
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.11" data-path="08day/section.7.1.html">
            
                
                    <a href="../08day/section.7.1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.11.</b>
                        
                        python中的包
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.12" data-path="08day/section.8.4.html">
            
                
                    <a href="../08day/section.8.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.12.</b>
                        
                        使用pip来安装模块
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="9" data-path="12day/index.html">
            
                
                    <a href="../12day/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.</b>
                        
                        强化练习
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="9.1" data-path="09day/section.12.html">
            
                
                    <a href="../09day/section.12.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.1.</b>
                        
                        应用:反恐精英
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="12day/section.3.html">
            
                
                    <a href="../12day/section.3.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.2.</b>
                        
                        给程序传参数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.3" data-path="12day/section.4.html">
            
                
                    <a href="../12day/section.4.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.3.</b>
                        
                        列表推导式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.4" data-path="12day/section.5.html">
            
                
                    <a href="../12day/section.5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.4.</b>
                        
                        set、list、tuple
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10" data-path="07day/index.html">
            
                
                    <a href="../07day/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.</b>
                        
                        应用:飞机大战
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="10.1" data-path="10day/section.5.html">
            
                
                    <a href="../10day/section.5.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.1.</b>
                        
                        搭建界面
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.2" data-path="10day/section.6.html">
            
                
                    <a href="../10day/section.6.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.2.</b>
                        
                        检测键盘
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.3" data-path="10day/section.7.html">
            
                
                    <a href="../10day/section.7.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.3.</b>
                        
                        显示、控制玩具飞机-面向过程
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.4" data-path="10day/section.8.html">
            
                
                    <a href="../10day/section.8.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.4.</b>
                        
                        显示、控制玩具飞机-面向对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.5" data-path="10day/section.9.html">
            
                
                    <a href="../10day/section.9.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.5.</b>
                        
                        玩家飞机发射子弹
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.6" data-path="10day/section.12.html">
            
                
                    <a href="../10day/section.12.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.6.</b>
                        
                        显示敌机
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.7" data-path="10day/section.11.html">
            
                
                    <a href="../10day/section.11.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.7.</b>
                        
                        优化代码
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.8" data-path="10day/section.13.html">
            
                
                    <a href="../10day/section.13.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.8.</b>
                        
                        让敌机移动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.9" data-path="10day/section.14.html">
            
                
                    <a href="../10day/section.14.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.9.</b>
                        
                        敌机发射子弹
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="10.10" data-path="10day/section.16.html">
            
                
                    <a href="../10day/section.16.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.10.</b>
                        
                        代码优化-抽象出基类
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    本書使用 GitBook 釋出
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >python基础语言</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x6A21;&#x5757;">&#x6A21;&#x5757;</h1>
<h2 id="python&#x4E2D;&#x7684;&#x6A21;&#x5757;"><1>Python&#x4E2D;&#x7684;&#x6A21;&#x5757;</1></h2>
<p>&#x6709;&#x8FC7;C&#x8BED;&#x8A00;&#x7F16;&#x7A0B;&#x7ECF;&#x9A8C;&#x7684;&#x670B;&#x53CB;&#x90FD;&#x77E5;&#x9053;&#x5728;C&#x8BED;&#x8A00;&#x4E2D;&#x5982;&#x679C;&#x8981;&#x5F15;&#x7528;<code>sqrt&#x51FD;&#x6570;</code>&#xFF0C;&#x5FC5;&#x987B;&#x7528;&#x8BED;&#x53E5;<code>#include &lt;math.h&gt;</code>&#x5F15;&#x5165;math.h&#x8FD9;&#x4E2A;&#x5934;&#x6587;&#x4EF6;&#xFF0C;&#x5426;&#x5219;&#x662F;&#x65E0;&#x6CD5;&#x6B63;&#x5E38;&#x8FDB;&#x884C;&#x8C03;&#x7528;&#x7684;&#x3002;</p>
<p>&#x90A3;&#x4E48;&#x5728;Python&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x8981;&#x5F15;&#x7528;&#x4E00;&#x4E9B;&#x5176;&#x4ED6;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x8BE5;&#x600E;&#x4E48;&#x5904;&#x7406;&#x5462;&#xFF1F;</p>
<p>&#x5728;Python&#x4E2D;&#x6709;&#x4E00;&#x4E2A;&#x6982;&#x5FF5;&#x53EB;&#x505A;&#x6A21;&#x5757;&#xFF08;module&#xFF09;&#xFF0C;&#x8FD9;&#x4E2A;&#x548C;C&#x8BED;&#x8A00;&#x4E2D;&#x7684;&#x5934;&#x6587;&#x4EF6;&#x4EE5;&#x53CA;Java&#x4E2D;&#x7684;&#x5305;&#x5F88;&#x7C7B;&#x4F3C;&#xFF0C;&#x6BD4;&#x5982;&#x5728;Python&#x4E2D;&#x8981;&#x8C03;&#x7528;<code>sqrt&#x51FD;&#x6570;</code>&#xFF0C;&#x5FC5;&#x987B;&#x7528;import&#x5173;&#x952E;&#x5B57;&#x5F15;&#x5165;math&#x8FD9;&#x4E2A;&#x6A21;&#x5757;&#xFF0C;&#x4E0B;&#x9762;&#x5C31;&#x6765;&#x4E86;&#x89E3;&#x4E00;&#x4E0B;Python&#x4E2D;&#x7684;&#x6A21;&#x5757;&#x3002;</p>
<p><span class="pg-emphasize pg-emphasize-yellow" style="background: #fff700;">&#x8BF4;&#x7684;&#x901A;&#x4FD7;&#x70B9;&#xFF1A;&#x6A21;&#x5757;&#x5C31;&#x597D;&#x6BD4;&#x662F;&#x5DE5;&#x5177;&#x5305;&#xFF0C;&#x8981;&#x60F3;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x5DE5;&#x5177;&#x5305;&#x4E2D;&#x7684;&#x5DE5;&#x5177;(&#x5C31;&#x597D;&#x6BD4;&#x51FD;&#x6570;)&#xFF0C;&#x5C31;&#x9700;&#x8981;&#x5BFC;&#x5165;&#x8FD9;&#x4E2A;&#x6A21;&#x5757;</span></p>
<h2 id="import"><2><span class="pg-emphasize pg-emphasize-yellow" style="background: #fff700;">import</span></2></h2>
<p>&#x5728;Python&#x4E2D;&#x7528;&#x5173;&#x952E;&#x5B57;<code>import</code>&#x6765;&#x5F15;&#x5165;&#x67D0;&#x4E2A;&#x6A21;&#x5757;&#xFF0C;&#x6BD4;&#x5982;&#x8981;&#x5F15;&#x7528;&#x6A21;&#x5757;math&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x5728;&#x6587;&#x4EF6;&#x6700;&#x5F00;&#x59CB;&#x7684;&#x5730;&#x65B9;&#x7528;import math&#x6765;&#x5F15;&#x5165;&#x3002;</p>
<p>&#x5F62;&#x5982;:    </p>
<pre><code class="lang-python">    <span class="hljs-keyword">import</span> module1,mudule2...
</code></pre>
<p>&#x5F53;&#x89E3;&#x91CA;&#x5668;&#x9047;&#x5230;import&#x8BED;&#x53E5;&#xFF0C;&#x5982;&#x679C;&#x6A21;&#x5757;&#x5728;&#x5F53;&#x524D;&#x7684;&#x641C;&#x7D22;&#x8DEF;&#x5F84;&#x5C31;&#x4F1A;&#x88AB;&#x5BFC;&#x5165;&#x3002;</p>
<p>&#x5728;&#x8C03;&#x7528;math&#x6A21;&#x5757;&#x4E2D;&#x7684;&#x51FD;&#x6570;&#x65F6;&#xFF0C;&#x5FC5;&#x987B;&#x8FD9;&#x6837;&#x5F15;&#x7528;&#xFF1A;</p>
<pre><code class="lang-python">&#x3000;&#x3000;&#x6A21;&#x5757;&#x540D;.&#x51FD;&#x6570;&#x540D;
</code></pre>
<ul>
<li><p>&#x60F3;&#x4E00;&#x60F3;:</p>
<blockquote>
<p>&#x4E3A;&#x4EC0;&#x4E48;&#x5FC5;&#x987B;&#x52A0;&#x4E0A;&#x6A21;&#x5757;&#x540D;&#x8C03;&#x7528;&#x5462;&#xFF1F;</p>
</blockquote>
</li>
<li><p>&#x7B54;:</p>
<blockquote>
<p>&#x56E0;&#x4E3A;&#x53EF;&#x80FD;&#x5B58;&#x5728;&#x8FD9;&#x6837;&#x4E00;&#x79CD;&#x60C5;&#x51B5;&#xFF1A;&#x5728;&#x591A;&#x4E2A;&#x6A21;&#x5757;&#x4E2D;&#x542B;&#x6709;&#x76F8;&#x540C;&#x540D;&#x79F0;&#x7684;&#x51FD;&#x6570;&#xFF0C;&#x6B64;&#x65F6;&#x5982;&#x679C;&#x53EA;&#x662F;&#x901A;&#x8FC7;&#x51FD;&#x6570;&#x540D;&#x6765;&#x8C03;&#x7528;&#xFF0C;&#x89E3;&#x91CA;&#x5668;&#x65E0;&#x6CD5;&#x77E5;&#x9053;&#x5230;&#x5E95;&#x8981;&#x8C03;&#x7528;&#x54EA;&#x4E2A;&#x51FD;&#x6570;&#x3002;&#x6240;&#x4EE5;&#x5982;&#x679C;&#x50CF;&#x4E0A;&#x8FF0;&#x8FD9;&#x6837;&#x5F15;&#x5165;&#x6A21;&#x5757;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x5FC5;&#x987B;&#x52A0;&#x4E0A;&#x6A21;&#x5757;&#x540D;</p>
</blockquote>
</li>
</ul>
<pre><code class="lang-python">    <span class="hljs-keyword">import</span> math

    <span class="hljs-comment">#&#x8FD9;&#x6837;&#x4F1A;&#x62A5;&#x9519;</span>
    <span class="hljs-keyword">print</span> sqrt(<span class="hljs-number">2</span>)

    <span class="hljs-comment">#&#x8FD9;&#x6837;&#x624D;&#x80FD;&#x6B63;&#x786E;&#x8F93;&#x51FA;&#x7ED3;&#x679C;</span>
    <span class="hljs-keyword">print</span> math.sqrt(<span class="hljs-number">2</span>)
</code></pre>
<p>&#x6709;&#x65F6;&#x5019;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x7528;&#x5230;&#x6A21;&#x5757;&#x4E2D;&#x7684;&#x67D0;&#x4E2A;&#x51FD;&#x6570;&#xFF0C;&#x53EA;&#x9700;&#x8981;&#x5F15;&#x5165;&#x8BE5;&#x51FD;&#x6570;&#x5373;&#x53EF;&#xFF0C;&#x6B64;&#x65F6;&#x53EF;&#x4EE5;&#x7528;&#x4E0B;&#x9762;&#x65B9;&#x6CD5;&#x5B9E;&#x73B0;&#xFF1A;</p>
<pre><code class="lang-python">    <span class="hljs-keyword">from</span> &#x6A21;&#x5757;&#x540D; <span class="hljs-keyword">import</span> &#x51FD;&#x6570;&#x540D;<span class="hljs-number">1</span>,&#x51FD;&#x6570;&#x540D;<span class="hljs-number">2.</span>...
</code></pre>
<p>&#x4E0D;&#x4EC5;&#x53EF;&#x4EE5;&#x5F15;&#x5165;&#x51FD;&#x6570;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x5F15;&#x5165;&#x4E00;&#x4E9B;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x3001;&#x7C7B;&#x7B49;</p>
<ul>
<li><p>&#x6CE8;&#x610F;:</p>
<blockquote>
<ul>
<li><p>&#x901A;&#x8FC7;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x5F15;&#x5165;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x65F6;&#x53EA;&#x80FD;&#x7ED9;&#x51FA;&#x51FD;&#x6570;&#x540D;&#xFF0C;&#x4E0D;&#x80FD;&#x7ED9;&#x51FA;&#x6A21;&#x5757;&#x540D;&#xFF0C;&#x4F46;&#x662F;&#x5F53;&#x4E24;&#x4E2A;&#x6A21;&#x5757;&#x4E2D;&#x542B;&#x6709;&#x76F8;&#x540C;&#x540D;&#x79F0;&#x51FD;&#x6570;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x540E;&#x9762;&#x4E00;&#x6B21;&#x5F15;&#x5165;&#x4F1A;&#x8986;&#x76D6;&#x524D;&#x4E00;&#x6B21;&#x5F15;&#x5165;&#x3002;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x5047;&#x5982;&#x6A21;&#x5757;A&#x4E2D;&#x6709;&#x51FD;&#x6570;function( )&#xFF0C;&#x5728;&#x6A21;&#x5757;B&#x4E2D;&#x4E5F;&#x6709;&#x51FD;&#x6570;function( )&#xFF0C;&#x5982;&#x679C;&#x5F15;&#x5165;A&#x4E2D;&#x7684;function&#x5728;&#x5148;&#x3001;B&#x4E2D;&#x7684;function&#x5728;&#x540E;&#xFF0C;&#x90A3;&#x4E48;&#x5F53;&#x8C03;&#x7528;function&#x51FD;&#x6570;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x662F;&#x53BB;&#x6267;&#x884C;&#x6A21;&#x5757;B&#x4E2D;&#x7684;function&#x51FD;&#x6570;&#x3002;</p>
</li>
<li><p>&#x5982;&#x679C;&#x60F3;&#x4E00;&#x6B21;&#x6027;&#x5F15;&#x5165;math&#x4E2D;&#x6240;&#x6709;&#x7684;&#x4E1C;&#x897F;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;from math import *&#x6765;&#x5B9E;&#x73B0;</p>
</li>
</ul>
</blockquote>
</li>
</ul>
<h2 id="fromimport"><3><span class="pg-emphasize pg-emphasize-yellow" style="background: #fff700;">from&#x2026;import</span></3></h2>
<p>Python&#x7684;from&#x8BED;&#x53E5;&#x8BA9;&#x4F60;&#x4ECE;&#x6A21;&#x5757;&#x4E2D;&#x5BFC;&#x5165;&#x4E00;&#x4E2A;&#x6307;&#x5B9A;&#x7684;&#x90E8;&#x5206;&#x5230;&#x5F53;&#x524D;&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x4E2D;</p>
<p>&#x8BED;&#x6CD5;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python">    <span class="hljs-keyword">from</span> modname <span class="hljs-keyword">import</span> name1[, name2[, ... nameN]]
</code></pre>
<p>&#x4F8B;&#x5982;&#xFF0C;&#x8981;&#x5BFC;&#x5165;&#x6A21;&#x5757;fib&#x7684;fibonacci&#x51FD;&#x6570;&#xFF0C;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x8BED;&#x53E5;&#xFF1A;</p>
<pre><code class="lang-python">    <span class="hljs-keyword">from</span> fib <span class="hljs-keyword">import</span> fibonacci
</code></pre>
<h3 id="&#x6CE8;&#x610F;">&#x6CE8;&#x610F;</h3>
<ul>
<li>&#x4E0D;&#x4F1A;&#x628A;&#x6574;&#x4E2A;fib&#x6A21;&#x5757;&#x5BFC;&#x5165;&#x5230;&#x5F53;&#x524D;&#x7684;&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x4E2D;&#xFF0C;&#x5B83;&#x53EA;&#x4F1A;&#x5C06;fib&#x91CC;&#x7684;fibonacci&#x5355;&#x4E2A;&#x5F15;&#x5165;</li>
</ul>
<h2 id="from--import-"><4><span class="pg-emphasize pg-emphasize-yellow" style="background: #fff700;">from &#x2026; import *</span></4></h2>
<p>&#x628A;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#x7684;&#x6240;&#x6709;&#x5185;&#x5BB9;&#x5168;&#x90FD;&#x5BFC;&#x5165;&#x5230;&#x5F53;&#x524D;&#x7684;&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x4E5F;&#x662F;&#x53EF;&#x884C;&#x7684;&#xFF0C;&#x53EA;&#x9700;&#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x58F0;&#x660E;&#xFF1A;</p>
<pre><code class="lang-python">    <span class="hljs-keyword">from</span> modname <span class="hljs-keyword">import</span> *
</code></pre>
<h3 id="&#x6CE8;&#x610F;">&#x6CE8;&#x610F;</h3>
<ul>
<li>&#x8FD9;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x65B9;&#x6CD5;&#x6765;&#x5BFC;&#x5165;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x9879;&#x76EE;&#x3002;&#x7136;&#x800C;&#x8FD9;&#x79CD;&#x58F0;&#x660E;&#x4E0D;&#x8BE5;&#x88AB;&#x8FC7;&#x591A;&#x5730;&#x4F7F;&#x7528;&#x3002;</li>
</ul>
<h2 id="as"><5> <span class="pg-emphasize pg-emphasize-yellow" style="background: #fff700;">as</span></5></h2>
<pre><code class="lang-python">
    In [1]: import time as tt

    In [2]: time.sleep(1)
    ---------------------------------------------------------------------------
    NameError                                 Traceback (most recent call last)
    &lt;ipython-input-2-07a34f5b1e42&gt; in &lt;module&gt;()
    ----&gt; 1 time.sleep(1)

    NameError: name &apos;time&apos; is not defined

    In [3]: 

    In [3]: 

    In [3]: tt.sleep(1)

    In [4]: 

    In [4]: 

    In [4]: from time import sleep as sp

    In [5]: sleep(1)
    ---------------------------------------------------------------------------
    NameError                                 Traceback (most recent call last)
    &lt;ipython-input-5-82e5c2913b44&gt; in &lt;module&gt;()
    ----&gt; 1 sleep(1)

    NameError: name &apos;sleep&apos; is not defined

    In [6]: 

    In [6]: 

    In [6]: sp(1)

    In [7]:
</code></pre>
<h2 id="&#x5B9A;&#x4F4D;&#x6A21;&#x5757;"><6>&#x5B9A;&#x4F4D;&#x6A21;&#x5757;</6></h2>
<p>&#x5F53;&#x4F60;&#x5BFC;&#x5165;&#x4E00;&#x4E2A;&#x6A21;&#x5757;&#xFF0C;Python&#x89E3;&#x6790;&#x5668;&#x5BF9;&#x6A21;&#x5757;&#x4F4D;&#x7F6E;&#x7684;&#x641C;&#x7D22;&#x987A;&#x5E8F;&#x662F;&#xFF1A;</p>
<ol>
<li>&#x5F53;&#x524D;&#x76EE;&#x5F55;</li>
<li>&#x5982;&#x679C;&#x4E0D;&#x5728;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#xFF0C;Python&#x5219;&#x641C;&#x7D22;&#x5728;shell&#x53D8;&#x91CF;PYTHONPATH&#x4E0B;&#x7684;&#x6BCF;&#x4E2A;&#x76EE;&#x5F55;&#x3002;</li>
<li>&#x5982;&#x679C;&#x90FD;&#x627E;&#x4E0D;&#x5230;&#xFF0C;Python&#x4F1A;&#x5BDF;&#x770B;&#x9ED8;&#x8BA4;&#x8DEF;&#x5F84;&#x3002;UNIX&#x4E0B;&#xFF0C;&#x9ED8;&#x8BA4;&#x8DEF;&#x5F84;&#x4E00;&#x822C;&#x4E3A;/usr/local/lib/python/</li>
<li>&#x6A21;&#x5757;&#x641C;&#x7D22;&#x8DEF;&#x5F84;&#x5B58;&#x50A8;&#x5728;<span class="pg-emphasize pg-emphasize-yellow" style="background: #fff700;">system&#x6A21;&#x5757;&#x7684;sys.path&#x53D8;&#x91CF;</span>&#x4E2D;&#x3002;&#x53D8;&#x91CF;&#x91CC;&#x5305;&#x542B;&#x5F53;&#x524D;&#x76EE;&#x5F55;&#xFF0C;PYTHONPATH&#x548C;&#x7531;&#x5B89;&#x88C5;&#x8FC7;&#x7A0B;&#x51B3;&#x5B9A;&#x7684;&#x9ED8;&#x8BA4;&#x76EE;&#x5F55;&#x3002;</li>
</ol>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../10day/section.3.2.html" class="navigation navigation-prev " aria-label="Previous page: 异常处理中抛出异常"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../08day/section.8.html" class="navigation navigation-next " aria-label="Next page: 模块制作"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-splitter/splitter.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"toggle-chapters":{},"splitter":{},"emphasize":{},"highlight":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
    </body>
    <!-- End of book python基础语言 -->
</html>
